/**
 * 
 */
package com.pactera.android.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.util.Log;

import com.pactera.android.service.NotificationService;

/**
 * @author David Zheng
 *
 */
public class NetworkReceiver extends BroadcastReceiver {
	
	static final String TAG = "NetworkReceiver";
	
	/* (non-Javadoc)
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		boolean isNetworkDown = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);		
		
		if(isNetworkDown) {
			Log.d(TAG, "stop Notification service");
			context.stopService(new Intent(context, NotificationService.class));
		} else {
			Log.d(TAG, "start Notification service");
			context.startService(new Intent(context, NotificationService.class));
		}

	}

}
